<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
<title>漂亮的响应式Bootstrap后台管理系统模板MatAdmin</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/bootstrap.min.css" />
<!-- <link rel="stylesheet" href="/phpwmscm/PUBLIC/css/bootstrap-responsive.min.css" /> -->
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/fullcalendar.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/matrix-style.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/matrix-media.css" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/index.css" />
<link href="/phpwmscm/PUBLIC/font-awesome/css/font-awesome.css" rel="stylesheet" />
<link rel="stylesheet" href="/phpwmscm/PUBLIC/css/jquery.gritter.css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
<script src="/phpwmscm/PUBLIC/js/jquery-1.8.0.min.js"></script> 
    <style type="text/css">
		#allmap{width:100%;height:450px;}
	</style>
	<style>
        html, body, #container {
            height: 100%;
            width: 100%;
        }

        .amap-icon img,
        .amap-marker-content img{
            width: 25px;
            height: 34px;
        }

        .marker {
            position: absolute;
            top: -20px;
            right: -118px;
            color: #fff;
            padding: 4px 10px;
            box-shadow: 1px 1px 1px rgba(10, 10, 10, .2);
            white-space: nowrap;
            font-size: 12px;
            font-family: "";
            background-color: #25A5F7;
            border-radius: 3px;
        }

        .input-card{
            width: 18rem;
            z-index: 170;
        }

        .input-card .btn{
            margin-right: .8rem;
        }

        .input-card .btn:last-child{
            margin-right: 0;
        }
    </style>
   
<style>

.parent {
	display: block;
	height:0px;
    padding-bottom:100%
}

.parent {
	 writing-mode: horizontal-tb; 
}

.child {
	margin: 10px 10px 10px 10px;
	border: 5px solid black;
	padding: 5px;
	width: 450px;
	height: 750px;
	text-align: center;
	background: lightblue;
	writing-mode: horizontal-tb;
	display: inline-block;
}
</style>
<style>
#newwwf{position:relative;width:100%;height:1200px;border:2px solid #000;margin:10px auto;overflow:hidden;}
#allmap,#bottom{height:700px;overflow:hidden;}
#line{position:absolute;top:58%;width:100%;height:4px;overflow:hidden;margin-top:-2px;background:red;cursor:n-resize;}
</style>
<!-- <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=hNx4DUGHj4NRfZZIlfmSkkaxpwe1r8Zj"></script> -->
	  <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=9236cca4395c6f2a6e7dbd58677501c5"></script>   
</head>
<body>
        
<!--Header-part-->
<div id="header">
  <h1><a href="dashboard.html">MatAdmin</a></h1>
</div>
<!--close-Header-part-->
<!--top-Header-menu-->
<div id="user-nav" class="navbar navbar-inverse">
  <ul class="nav">
    <li  class="dropdown" id="profile-messages" ><a title="" href="#" data-toggle="dropdown" data-target="#profile-messages" class="dropdown-toggle"><i class="icon icon-user"></i>  <span id="userbeifn" class="text"><?php echo ($user); ?></span><b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a href="#"><i class="icon-user"></i> 我的资料</a></li>
        <li class="divider"></li>
        <li><a href="#"><i class="icon-check"></i> 我的任务</a></li>
        <li class="divider"></li>
        <li><a href="<?php echo U('Login/logout');?>"><i class="icon-key"></i> 退出</a></li>
      </ul>
    </li>
    <li class="dropdown" id="menu-messages"><a href="#" data-toggle="dropdown" data-target="#menu-messages" class="dropdown-toggle"><i class="icon icon-envelope"></i> <span class="text">消息</span> <span class="label label-important">5</span> <b class="caret"></b></a>
      <ul class="dropdown-menu">
        <li><a class="sAdd" title="" href="#"><i class="icon-plus"></i> 新消息</a></li>
        <li class="divider"></li>
        <li><a class="sInbox" title="" href="#"><i class="icon-envelope"></i> 收件箱</a></li>
        <li class="divider"></li>
        <li><a class="sOutbox" title="" href="#"><i class="icon-arrow-up"></i> 发件箱</a></li>
        <li class="divider"></li>
        <li><a class="sTrash" title="" href="#"><i class="icon-trash"></i> 发送</a></li>
      </ul>
    </li>
    <li class=""><a title="" href="#"><i class="icon icon-cog"></i> <span class="text">设置</span></a></li>
    <li class=""><a title="" href="<?php echo U('Login/logout');?>"><i class="icon icon-share-alt"></i> <span class="text">退出</span></a></li>
  </ul>
</div>
<!--close-top-Header-menu-->
<!--start-top-serch-->
<div id="search">
  <input type="text" placeholder="输入搜索内容..."/>
  <button type="submit" class="tip-bottom" title="Search"><i class="icon-search icon-white"></i></button>
</div>
<!--close-top-serch-->
<div id="sidebar"><a href="#" class="visible-phone"><i class="icon-home"></i> 控制台</a>
  <ul>
    <!-- <li><a href="<?php echo U('Index/index');?>"><i class="icon-home"></i> <span>首页</span></a> </li>
    <li> <a href="<?php echo U('Log/index');?>"><i class="icon-signal"></i> <span>库存单品编码</span></a> </li>
    <li> <a href="<?php echo U('Lsdl/index');?>"><i class="icon-signal"></i> <span>客户门店添加</span></a> </li>
    <li class="active"> <a href="<?php echo U('Ls/index');?>"><i class="icon-signal"></i> <span>门店报单编辑</span></a> </li>
    <li> <a href="<?php echo U('Lsrb/index');?>"><i class="icon-signal"></i> <span>已报订单确认</span></a> </li>
    <li> <a href="<?php echo U('Nslsrb/index');?>"><i class="icon-signal"></i> <span>日报新增删除</span></a> </li>
    <li > <a href="<?php echo U('Sc/index');?>"><i class="icon-signal"></i> <span>商超批量派车</span></a> </li>
    <li> <a href="<?php echo U('Scdl/index');?>"><i class="icon-signal"></i> <span>商超独立派车</span></a> </li>
    <li> <a href="<?php echo U('Wpcmd/index');?>"><i class="icon-signal"></i> <span>未派订单处理</span></a> </li>    -->
  </ul>
</div>
<!--sidebar-menu-->

<!--main-container-part-->
<div id="content">
<!--breadcrumbs-->
  <div id="content-header">
    <div id="f"> <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> 首页</a></div>
  </div>
<!-- End-breadcrumbs -->

<!-- Action boxes -->

  <div id="newwwf" class="" >
    <div id="allmap"></div> 
    <div id="bottom"> 
    <div> 
    <!-- <form action="<?php echo U('ls/upfile');?>" enctype="multipart/form-data" method="post">
	 <input type="file" name="photo" /> <input type="submit" value="提交">
    </form> -->
    <!-- <button id="fbt6">加载配送信息</button>
    <button id="fbt1">追加</button>
	<button id="fbt2">删除</button>
	<button id="fbt3">保存</button>
	<button id="fbt4">预览</button>
	<button id="fbt5">提交</button>
	<button id="fbt7">提交并保存</button>
	<button id="fbt8">删除缓存</button>
	<button id="fbt9">无订单加载缓存</button>
    <datalist id="typelist"> 
    </datalist>-->
    <datalist id="typelist"> 
    </datalist>
             客户(非空):<input id="khm" type="text" value="cmxm">
	门店(非空):<input id="md" type="text" value="">
	收货人(非空):<input id="shr" type="text" value="">
	电话(非空):<input id="shrdh" type="text" value="">
	三方订单号:<input id="ddh" type="text" value="">
	<br>
	地址(非空):<input id="dz" class="span8" type="text" value="">
	经度(非空):<input id="jdz" class="span1" type="text" value="">
	纬度(非空):<input id="wdz" class="span1" type="text" value="">
	<br>
	订单备注:<input id="beizhu" class="span9" type="text" value="">
	<br>
	订单日期:<input type=date  id="db1" class=span2>
	配送日期:<input type=date  id="db2" class=span2>
	<select id="sel">
		<option value ="市内">市内</option>
		<option value ="零担">零担</option>
		<option value ="自提">自提</option>
	</select>
	<button id="fbt333">提交</button>	
	<hr>  	
	添加个数<input type="text" id="dpsm" class="span1" value=1>
	<button id="fbt111">追加</button>		
	<button id="fbt222">删除</button>
	</div>       
	<div  class="parent pre-scrollable" ><!-- 与wwf分离，来保存input变量 -->   
    <div  id="wwf"> 
                            <table id=tablea class="table table-bordered table-striped" >							
							<thead>
							<tr>
							    <th><nobr>选中</nobr></th>
							    <th><nobr>序号</nobr></th>
							    <th><nobr>商品编码</nobr></th>
							    <th style="color:#f0f"><nobr>品名</nobr></th>
							    <th><nobr>商品条码</nobr></th>
							    <th><nobr>单品规格</nobr></th>
							    <th><nobr>箱规</nobr></th>
							    <th><nobr>货物类型</nobr></th>
							    <th style="color:#f0f"><nobr>备注</nobr></th>
							    <th id="jsjs" style="color:#f0f"><nobr>件数</nobr></th>	
							    <th style="color:#21f"><nobr>真实库存</nobr></th>	
							    <th style="color:#21f"><nobr>虚拟库存</nobr></th>	
							    <th style="color:#21f"><nobr>备用</nobr></th>					    						 
							</tr>
							</thead>
							<tbody>
							<?php if(is_array($arr1)): $i = 0; $__LIST__ = $arr1;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
							    <!-- <th><input type=checkbox name=selected_book_id[] value=<?php echo ($vo["0"]); ?>></th>						
								<th><nobr><?php echo ($vo["1"]); ?></nobr></th>								
								<th><nobr><?php echo ($vo["2"]); ?></nobr></th>
								<td><nobr><?php echo ($vo["3"]); ?></nobr></td>								
								<th><nobr><?php echo ($vo["4"]); ?></nobr></th>
								<th><nobr><?php echo ($vo["5"]); ?></nobr></th>
								<th><nobr><?php echo ($vo["6"]); ?></nobr></th>
								<td><nobr><?php echo ($vo["7"]); ?></nobr></td>
								<th><nobr><?php echo ($vo["8"]); ?></nobr></th>
								<th><nobr><?php echo ($vo["9"]); ?></nobr></th>		 -->																																				
							</tr><?php endforeach; endif; else: echo "" ;endif; ?>	
							</tbody>							
						</table>     
	</div>    
	</div>
	</div>
	<div id="line"></div>
  </div>
<!-- End-Action boxes -->    

</div>

<!--end-main-container-part-->

<!--Footer-part-->

<div class="row-fluid">
  <div id="footer" class="span12">Copyright &copy; 2018.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a> </div>
</div>


<script src="/phpwmscm/PUBLIC/js/excanvas.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.ui.custom.js"></script> 
<script src="/phpwmscm/PUBLIC/js/bootstrap.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.flot.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.flot.resize.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.peity.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/fullcalendar.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.dashboard.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.gritter.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.interface.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.chat.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.validate.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.form_validation.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.wizard.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.uniform.js"></script> 
<script src="/phpwmscm/PUBLIC/js/select2.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.popover.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.dataTables.min.js"></script> 
<script src="/phpwmscm/PUBLIC/js/matrix.tables.js"></script> 
<script src="/phpwmscm/PUBLIC/js/mindmup-editabletable.js"></script> 
<script src="/phpwmscm/PUBLIC/js/numeric-input-example.js"></script> 
<script src="/phpwmscm/PUBLIC/js/jquery.mousewheel.js"></script>
<!--end-Footer-part-->
<script type="text/javascript">
 function wwe(id) {
	
	return document.getElementById(id);
	
} 
window.onload = function() {
	
	var oBox = wwe("newwwf"), oTop = wwe("allmap"), oBottom = wwe("bottom"), oLine = wwe("line");
	oLine.style.top=oTop.style.height;
	oLine.onmousedown = function(e) {
		
		//保存当前鼠标点击时的 y值。
		var disY = (e || event).clientY;
		//保存oLine到父元素的距离。
		oLine.top = oLine.offsetTop;
		//鼠标上下移动时的事件响应。
		document.onmousemove = function(e) {		
			//oLine的top值加上（当前鼠标移动后的y值减去鼠标点击按下时的y值），这个结果应该是oline的新y值。
			//oLine的原始高度加上鼠标的位置变化，就是新的y值。
			var iT = oLine.top + ((e || event).clientY - disY);			
			
			//上div y的最大值 395-396之间
			var maxT = oBox.clientHeight - oLine.offsetHeight;			
			
			//oLine的四个外边距为0
			oLine.style.margin = 0;
			
			//如果iT小于0 iT就等于0；大于maxT就等于maxT。
			iT < 0 && (iT = 0);
			iT > maxT && (iT = maxT);
			
			oLine.style.top = oTop.style.height = iT + "px";
			oBottom.style.height = oBox.clientHeight - iT + "px";
			return false;
		};	
		document.onmouseup = function() {
			document.onmousemove = null;
			document.onmouseup = null;	
			oLine.releaseCapture && oLine.releaseCapture()
		};
		oLine.setCapture && oLine.setCapture();
		return false;
	};
};
</script>
<script type="text/javascript">


//ajax 测试
$.post("/phpwmscm/admin.php/Admin/Ls/ceshi/",
		    {
		    
		    },
		    function(data,status){	
		    	switch (data) 
		    	{		    	
		        case "1":
		    	{
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsdl/index');?>'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='<?php echo U('Ls/index');?>'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsrb/index');?>'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Dddy/index');?>'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Rkcl/index');?>'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Ddgz/index');?>'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        	break;
		    	}
		    	
		        case "2":
		    	{
		        	$('#sidebar').children("ul").append("<li><a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsdl/index');?>'><i class='icon-signal'></i> <span>客户门店添加</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li class='active'> <a href='<?php echo U('Ls/index');?>'><i class='icon-signal'></i> <span>门店报单编辑</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Lsrb/index');?>'><i class='icon-signal'></i> <span>已报订单确认</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>"); 
		        break;
		    	}
		    	
		        case "3":
		    	{ 
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Index/index');?>'><i class='icon-home'></i> <span>首页</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Log/index');?>'><i class='icon-signal'></i> <span>库存单品编码</span></a> </li>");	
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Dddy/index');?>'><i class='icon-signal'></i> <span>订单打印处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Rkcl/index');?>'><i class='icon-signal'></i> <span>单品入库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Ddgz/index');?>'><i class='icon-signal'></i> <span>订单出库处理</span></a> </li>");
		        	$('#sidebar').children("ul").append("<li> <a href='<?php echo U('Kcgl/index');?>'><i class='icon-signal'></i> <span>库存数据查看</span></a> </li>");
		        	break;
		    	}
		    	
		        case "4":
		        {    	    	
		        	
		        break;
		        } 
		        
		        default: 
		        {
		    	break;
		        }
		        
		    	} 
		    	//$("#sidebar").find("li")[0].remove();    
		    });
/////////////////////////////////////////////////////////////////////////
//today保存当前日期，作为所有需要赋值date的值
////////////////////////////////////////////////////////////////////////
//取得日期
	function getDate(d1) {

		/* var	d2=Number(d1);//转换为数值。
		var time = new Date();
		var day = ("0" + (time.getDate()+d2)).slice(-2);
		
		var month = ("0" + (time.getMonth() + 1)).slice(-2);
		var today = time.getFullYear() + "-" + (month) + "-" + (day);
		
		return today; */
		var d2 = Number(d1);//转换为数值。
		var time = new Date();
		var n = time.getTime();
		//有多少天的间隔就加上相对应的秒数。
		//console.log(n); 
		n = n + d2 * 24 * 60 * 60 * 1000;
		//console.log(n); 

		var dd = new Date(+n+8*3600*1000);
		var today = dd.toISOString();
		return today.slice(0, 10);
		//console.log(n1.slice(0,10)); 
	}
	$('#db1').val(getDate(0));
	$('#db2').val(getDate(1));
////////////////////////////////////////////////////////////////////////
//新增
    var bjs=0
	$('#fbt111').click(function(){
		var temp=Number($('#dpsm').val())
		
		 if(!isNaN(temp))
			{
			   for(var aaa=0;aaa<temp;aaa++)
			   {
				bjs=bjs+1
				$('#tablea').children('tbody').append('<tr><th><input type=checkbox value=a99999></th><th>'+bjs+'</th><th></td><td></th><th></th><th></th><th></th><th></th>'
						    +'<td></td>'    
						    +'<td>0</td>'
				            +'<th>0</th>'
				            +'<th></th>'
				            +'<th>0</th>'
				            + '</tr>'
				            );  
			   }
			 
			}
		 		
		 $('#tablea').unbind();
		 $('#tablea').editableTableWidget();
		 $('#tablea').on('click keypress dblclick', showEditordp);
	});
	//删除
    $('#fbt222').click(function(){
    	var  temp2Arr="";//缓存check 
        
        //input:checkbox:checked 选中input下的checkbox的checked选中值。
      	 $('#tablea').find("input:checkbox:checked").each(function(){
      		var temp=$(this).val();
      		   $('#tablea').children('tbody').find("tr").each(function(){ 			   
      	      	  if(temp==$(this).find("input:checkbox:checked").val())
      	      	  {   	      	 
      			   $(this).remove();//先找到table的选中复选框值，再用这个值与table表体中每一行tr中的复选框值比对，两个值相同就删除当前行。   			  
      	      	  }
      	      	  });//从表格体中查找tr行，并找到每行中check-box的值。        		   
        	   });
    	//更新件数
      	 var jsqhjs=0;
	    	$('#tablea').find('tbody td').each(function () {
	    		if($(this).index()==9){
	    			 var temparr=Number($(this).text());
	    			 if(!isNaN(temparr)){
	    				 jsqhjs=jsqhjs+temparr;
	    			 }else{
	    				 //不是 数字 归零
	    				 $(this).text(0)
	    				 alert("件数字段不是数字");
	    			 }		    			
	    		}		    		
			});
	    $('#jsjs').text('件数'+'('+jsqhjs+')');
	    //重绘序号
	    var jsxuhao=1;
    	$('#tablea').find('tbody th').each(function () {
    		//console.log($(this).index());
    		//console.log($(this).text());
    		if($(this).index()==1){
    			$(this).text(jsxuhao);
    			jsxuhao=jsxuhao+1;
    			 }	    			  				    		
		});
    	bjs=jsxuhao-1;
	});
	
	//提交  
	//这里可以设定 时间少于某一时刻禁止 提交新订单。 
    $('#fbt333').click(function(){
    	
    	var r=confirm("是否提交!");
   		if (r==true)
   		{   
   			var temp1Arr = "";
			var temp2Arr = "";
			
		
			$('#tablea').children("tbody").children("tr")
						.children("td").each(function() {
							var temp = $(this).text();
							temp1Arr = temp1Arr + temp + ",";							
						});
			$('#tablea').children("tbody").children("tr")
						.children("th").each(function() {
							var temp = $(this).text();
							temp2Arr = temp2Arr + temp + ",";
						});			
            
            
			var temp1 = temp1Arr.slice(0, temp1Arr.length - 1);
			var temp2 = temp2Arr.slice(0, temp2Arr.length - 1);
			
			if($('#khm').val()!=""&&$('#md').val()!=""&&$('#shr').val()!=""&&$('#shrdh').val()!=""&&$('#dz').val()!=""&&$('#jdz').val()!=""&&$('#wdz').val()!=""&&bjs>0)
			{
								
				$.post("/phpwmscm/admin.php/Admin/Ls/ajaxtjsj/", {
					khm:$('#khm').val(),
					md:$('#md').val(),
					shr:$('#shr').val(),
					shrdh:$('#shrdh').val(),
					ddh:$('#ddh').val(),
					dz:$('#dz').val(),
					jdz:$('#jdz').val(),
					wdz:$('#wdz').val(),
					beizhu:$('#beizhu').val(),					
					db1:$('#db1').val(),
					db2:$('#db2').val(),
					sel:$('#sel').val(),
					arr1:temp1,
					arr2:temp2,
					user:$('#userbeifn').text()
				}, function(data, status) {
				    console.log(data);
				});
				//清空所有input
				$('#md').val("");
				$('#shr').val("");
				$('#shrdh').val("");
				$('#ddh').val("");
				$('#dz').val("");					
				$('#jdz').val("");	
				$('#wdz').val("");
				$('#beizhu').val("");
				//删除所有tr行
				$('#tablea').children('tbody').find("tr").each(function(){ 			       	      	
	     			   $(this).remove(); 			       	      	 
	     	     });
				//重置序号 
				bjs=0;
				//重置计算件数
				$('#jsjs').text('件数');
				alert("已提交!");
			}else{
				alert("请检查非空单元格是否为空或者是否有单品数据!");
			}	
		  //重新写入 j1		  
          $.post("/phpwmscm/admin.php/Admin/Ls/ajaxdppccxarqdp/", {
				
			}, function(data, status) {
				j1=$.parseJSON(data);	
				console.log(j1);
	      }); 
 		}
 		else
 		{			
 		    alert("未提交!");
 		}
    	
	});
	
	var a = 113.65;
	var b = 34.76;
	var map = new AMap.Map('allmap', {
		zoom : 11,//级别
		center : [ a, b ],//中心点坐标
	});
	var arrDbys = [];

    //处理地标，订单表头。
	$.post("/phpwmscm/admin.php/Admin/Ls/ajaxmddb/", {

			}, function(data, status) {
				 //console.log(data);
				//把地标名称和地标的经纬度，填写到高德地图标签里面。				
				data = data.split(',');//转换为数组		
				//console.log(data);
				for (var ig = 0; ig < data.length; ig=ig+8) {
					
					arrDbys[ig] = new AMap.Marker(
							{
								position : new AMap.LngLat(
										data[ig+6],
										data[ig+7])
							});
					arrDbys[ig].setLabel({
								offset : new AMap.Pixel(10, 0), //设置文本标注偏移量
								content : data[ig+2], //设置文本标注内容
								direction : 'right' //设置文本标注方位
							});
					arrDbys[ig].setMap(map);
					//设置鼠标按下的事件回调函数    wwf的input发生离开事件都触发	
					arrDbys[ig].on('mousedown',attribute);
				}

				//设置鼠标按下的事件回调函数 函数定义
				function attribute(e) {
					var p = e.target;					
					$('#md').val(p.getLabel().content);
					
					for (var ig = 0; ig < data.length; ig=ig+8) {
						if(p.getLabel().content==data[ig+2]){
							$('#shr').val(data[ig+3]);
							$('#shrdh').val(data[ig+4]);
							$('#dz').val(data[ig+5]);
							$('#jdz').val(data[ig+6]);
							$('#wdz').val(data[ig+7]);
							
						}
					}
				}
				
			});
//按单品计算 库存数目
var j1;
$.post("/phpwmscm/admin.php/Admin/Ls/ajaxdppccxarqdp/", {
				
			}, function(data, status) {
				j1=$.parseJSON(data);	
				console.log(j1);
	}); 

   var act;//这个变量在js中赋值，保存当前表格td焦点。  
   var inputlist="";//缓存单品信息。
   //取回单品信息
	$.post("/phpwmscm/admin.php/Admin/Ls/ajaxdpbm/", {

	}, function(data, status) {
					
		inputlist = data.split(',');//转换为数组		
		//console.log(inputlist);
	});
   //生成下拉列表框。
	function showEditordp()
	{  
		
		
		 $('#typelist').empty();//删除datalist的所有子元素。
		 switch (act.index()) 
		 {
		    case 3:
		    	{ 	    
		    	$('#typelist').append('<option value=""></option>');//先加个空白值。
		    	for (var ig = 0; ig < inputlist.length; ig=ig+9) 
		    		{  	    		    
		    			$('#typelist').append('<option value="' + inputlist[ig+2] + '"></option>');
		    		}   
		        break;
		    	}
		    	    
		    default: 
		        {
		    	break;
		        }
		} 
		
	}

	$('#wwf').parent().find("input").blur(function(e){	
		 //console.log(act.text());
		 //console.log(act.index());
		 switch (act.index()) 
		 {
		    case 3:
		    	{ 
		    	 //console.log(act.parent().html());
		    	
		    	
		    	//以index标记对当前单元格的同辈进行赋值。
		    	for (var ig = 0; ig < inputlist.length; ig=ig+9) 
		    		{ 
		    		//清空开关
		    	     var qkkg=0;
		    			if(act.text()==inputlist[ig+2]){
		    			  act.prev().text(inputlist[ig+1]);
		    			  act.next().text(inputlist[ig+3]);
		    			  act.next().next().text(inputlist[ig+4]);
		    			  act.next().next().next().text(inputlist[ig+5]);
		    			  act.next().next().next().next().text(inputlist[ig+8]);
		    			  //更新数据时找到对应库存。
		    				for (var it = 0; it < j1.length; it=it+1) 
				    		{ 
		    					if(act.text()==j1[it]["pinming"]){
		    						  act.next().next().next().next().next().next().next().text(j1[it]["zskc"]);
		    						  act.next().next().next().next().next().next().next().next().text(j1[it]["xnkc"]);
		    					}
		    					
				    		}
		    			  break;
		    		    }else{
		    		    	//没有找到变为1 
		    		    	qkkg=1;
		    		    	
		    		    } 		    		    					    			
		    		}
		    	//清空
		    	if(qkkg==1){
		    		 act.text("");
		    		 act.prev().text("");
	    			 act.next().text("");
	    			 act.next().next().text("");
	    			 act.next().next().next().text("");
	    			 act.next().next().next().next().text("");
	    			 alert("单品不在库存或单元格为空，请添加！");
		    	}
		    	//抄码不用折合件
		    	/*  var bcs=Number(act.parent().find('th').eq(5).text());
	    		 var cs=Number(act.parent().find('td').eq(2).text());
	    		 //console.log(bcs);
	    		 //console.log(cs);
	    		 if(!isNaN(cs)&&!isNaN(bcs)){
	    			 var temp=cs/bcs;
	    			 act.parent().find('th').last().text(temp);
	    		 }  */
		        break;
		    	}
		    case 9:
	    	{ 	    
	    	    var jsqhjs=0;
		    	$('#tablea').find('tbody td').each(function () {
		    		if($(this).index()==9){
		    			 var temparr=Number($(this).text());
		    			 if(!isNaN(temparr)){
		    				 jsqhjs=jsqhjs+temparr;
		    			 }else{
		    				 //不是 数字 归零
		    				 $(this).text(0)
		    				 alert("件数字段不是数字");
		    			 }		    			
		    		}		    		
				});
		    	$('#jsjs').text('件数'+'('+jsqhjs+')');
		    	//抄码不用折合件
		    	/*  var bcs=Number(act.parent().find('th').eq(5).text());
	    		 var cs=Number(act.parent().find('td').eq(2).text());
	    		 //console.log(bcs);
	    		 //console.log(cs);
	    		 if(!isNaN(cs)&&!isNaN(bcs)){
	    			 var temp=cs/bcs;
	    			 act.parent().find('th').last().text(temp);
	    		 }  */
	            break;
	    	}
		   
		    	    
		    default: 
		        {
		    	break;
		        }
		} 	    					 
	  });

</script>
</body>
</html>